package com.zryc.shop.pms.controller;

import com.zryc.shop.base.Result;
import com.zryc.shop.pms.entity.SkuStock;
import com.zryc.shop.pms.service.ISkuStockService;
import com.zryc.shop.ums.entity.Resource;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.stereotype.Controller;

import java.util.List;

/**
 * <p>
 * sku的库存 前端控制器
 * </p>
 *
 * @author zhaozhao
 * @since 2024-01-18
 */
@RestController
@Api(tags = "SKU库存管理接口列表")
@RequestMapping("/pms/sku")
public class SkuStockController {

    @Autowired
    private ISkuStockService skuStockService;

    @GetMapping("/{pid}")
    @ApiOperation("查询某个商品的SKU库存列表")
    public Result skuById(@PathVariable Long pid, @RequestParam(required = false) String keyword) {
        return Result.ok(skuStockService.getByProductId(pid,keyword));
    }

    @PostMapping("/update/{pid}")
    @ApiOperation("更新SKU库存量")
    public Result updateSkuStock(@PathVariable Long pid, @RequestBody List<SkuStock> skuStockList){
        return Result.ok(skuStockService.updateSkuStock(pid,skuStockList));
    }
}
